<template>
    <h1>借款项目列表</h1>

    <table>
        <thead>
            <tr>
                <th>借款编号</th>
                <th>借款名称</th>
                <th>借款最高年限</th>
                <th>借款最高额度</th>
                <th>借款介绍</th>
                <th>借款利率</th>
                <th>操作</th>
            </tr>
        </thead>

        <tbody>
            <tr v-for="item in Show">
                <td>{{ item.BM_Id }}</td>
                <td>{{ item.BM_Name }}</td>
                <td>{{ item.BM_Year }}</td>
                <td>{{ item.BM_Money }}</td>
                <td>{{ item.BM_Info }}</td>
                <td>{{ item.BMI_Interest }}</td>
                <td>
                    <a href="#" @click="Jump(item.BM_Id)" >借款</a>
                </td>
            </tr>
        </tbody>
    </table>


</template>

<script setup lang="ts">

import { ref,onMounted } from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router'


const router = useRouter()

const Show = ref([{
    BM_Id:'',
    BM_Name:'',
    BM_Year:'',
    BM_Money:'',
    BM_Info:'',
    BMI_Id:'',
    BMI_Year:'',
    BMI_Interest:''
}])

onMounted (()=>{
    ShowBorrow()
})

const ShowBorrow = ()=>{
    axios({
        method:'get',
        url:'http://localhost:56707/api/Borrow/ShowBorrow',
    })
    .then(res=>{
        Show.value = res.data
    })
    .catch(err=>{
        console.log(err);
    })
}

const Jump = (Id:string)=>{
    router.push({
        name:'UserBorrow',
        params:{
            Id:Id
        }
    })
}



</script>
